import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        int n = in.nextInt();
        int[] a = new int[n];
        for(int i = 0;i<n;i++){
            a[i] = in.nextInt();
        }
        int count = 0;
        int b = 1;
        while(b<a.length){
            if(b<a.length&&a[b]==a[b-1]){
                b++;
            }
            if(b<a.length&&a[b]>a[b-1]){
                while(b<a.length&&a[b]>a[b-1]){
                    b++;
                }
                b++;
                count++;
            }
            if(b<a.length&&a[b]<a[b-1]){
                while(b<a.length&&a[b]<a[b-1]){
                    b++;
                }
                count++;
            }
        }
        System.out.print(count);
    }
}